<div class="modal-body">
	<input type="hidden" id="id" name="id" value="${map.id}" />
	<input type="hidden" id="orgid" name="orgid" value="${map.orgid}" />
	<input type="hidden" id="zoom" name="zoom" value="${map.zoom}" />
	<input type="hidden" id="lng" name="lng" value="${map.lng}" />
	<input type="hidden" id="lat" name="lat" value="${map.lat}" />
	<div class="row">
		<div id="container" style="width: 100%; height: 500px;"></div>
	</div>
</div>


<script src="http://webapi.amap.com/maps?v=1.4.6&key=5dbb4532636218635d869311007581c9&callback=init"></script>
<script>
	var clickListener, map;
	function init() {
		var id = document.getElementById("id").value;
		var orgid = document.getElementById("orgid").value;
		var zoom = document.getElementById("zoom").value;
		var lng = document.getElementById("lng").value;
		var lat = document.getElementById("lat").value;
		clickListener, map = new AMap.Map('container', {
			resizeEnable : true,
			zoom : zoom
		});
		map.plugin([ "AMap.ToolBar" ], function() {
			map.addControl(new AMap.ToolBar());
		});
		map.setZoomAndCenter(zoom, [parseFloat(lng), parseFloat(lat)]);
		
		var markers;
		
		var url = getRootPath()+"/mapsetting/getMarker/"+orgid;
		baseAjax('POST',url,{},function(data){
			if(data.success){
				markers = data.data;
			}
	    });
		if(markers && markers.length > 0){
			var markId;
			var markType;
			for(var i=0;i<markers.length;i++){
				if(i == 0){
					markId = markers[i].id;
					markType = markers[i].type;
				}
				var iconTmp;
				if(markers[i].type == '采集器'){
					iconTmp = getRootPath()+'/resources/common/images/qxz30.png';
				}else if(markers[i].type == '设备'){
					iconTmp = getRootPath()+'/resources/common/images/camera30.png';
				}else if(markers[i].type == '基地'){
					iconTmp = getRootPath()+'/resources/common/images/home30.png';
				}
				var marker = new AMap.Marker({
		            icon: iconTmp,
		            extData: markers[i],
		            position: [parseFloat(markers[i].px), parseFloat(markers[i].py)]
		        });
		        marker.setMap(map);
		        marker.on('click', function() {
		            parent.markerOnclick(this.getExtData().id);
		        });
		        marker.on('mouseover', function() {
		        	var device = this.getExtData();
		        	var title = "["+device.type + ":"+device.devip+"|"+device.port+"]";
		        	this.setTitle(title);
		        });
			}
			if(markType && markType != '基地'){
				parent.markerOnclick(markId);
			}
		}
		
	}
	
	
	function baseAjax() {
	    var xmlhttp;
	    if (window.XMLHttpRequest) {
	        xmlhttp = new XMLHttpRequest();
	    } else if (window.ActiveXObject) {  
	        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");  
	    } else {  
	        xmlhttp = null;  
	        return;
	    }  
	    xmlhttp.open(arguments[0],arguments[1],false);
	    var callback = arguments[3];
	    xmlhttp.onreadystatechange = function(){
	        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
	            callback(JSON.parse(xmlhttp.responseText));
	        }
	    }
	    if (arguments[0] == 'GET') {
	        xmlhttp.send();
	    } else {
	        xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
	        xmlhttp.send('');
	    }
	}
	
	function getRootPath(){  
	    //获取当前网址，如： http://localhost:8083/uimcardprj/share/meun.jsp  
	    var curWwwPath=window.document.location.href;  
	    //获取主机地址之后的目录，如： uimcardprj/share/meun.jsp  
	    var pathName=window.document.location.pathname;  
	    var pos=curWwwPath.indexOf(pathName);  
	    //获取主机地址，如： http://localhost:8083  
	    var localhostPaht=curWwwPath.substring(0,pos);
	    return localhostPaht;  
	}  

</script>